﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace EncodingTest
{
    public class Test1
    {
        public static string Ascll() {
            Encoding enc = Encoding.GetEncoding(65001);
            Encoding altEnc = Encoding.GetEncoding("utf-8");
            Console.WriteLine("{0} = Code Page {1}: {2}", enc.EncodingName,
                              altEnc.CodePage, enc.Equals(altEnc));
            var a = (char)0x7b2c;
            var s = (char)31532;

            var aaa = (char)31532;
            var t = Char.ConvertFromUtf32(31532);
            var i = 31532;
            var ix=i.ToString("x4");
            var w = s.ToString();

            var str = "测试";
            var str1 = "t";

            var aaaa = Encoding.UTF8.GetBytes(str);
            var bbb = Encoding.UTF8.GetBytes(str1);
            var ace=Convert.ToString((char)187, 10);
            var c = (char)187;
            var eugb=Encoding.Unicode.GetBytes("测");
            var eugs=Encoding.Unicode.GetString(eugb);
            var augb=ASCIIEncoding.UTF8.GetBytes("测试");
            var bitys = new byte[2];
            bitys[0] = 220;
            bitys[1] = 231;

            var ss =Encoding.GetEncoding("gbk").GetBytes("茜");
            var gbks=Encoding.GetEncoding("gbk").GetString(bitys);
            var gu = GetUnicode("测");
            var ggggggg=Int32.Parse("7b2c", System.Globalization.NumberStyles.HexNumber);
            var wwwww = (char)ggggggg;
            var ttttt=wwwww.ToString();
            var aaaaa="测".ToCharArray();
            var rrrr=aaaaa[0];
            var iii=(int) rrrr;
           var heeee= System.Web.HttpUtility.HtmlDecode("&#31532;   &#x7b2c;");
            return "";
        }
        public static string GetUnicode(string text)
        {
            string result = "";
            for (int i = 0; i < text.Length; i++)
            {
                if ((int)text[i] > 32 && (int)text[i] < 127)
                {//32-127是英文字母
                    result += text[i].ToString();
                }
                else
                    result += string.Format("\\u{0:x4}", (int)text[i]);
            }
            return result;
        }
    }
    public class TestStatic {
        public static string testc{ get; set; }
    }
}